<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" href="lib/layui-v2.5.5/css/layui.css" media="all">
		<link rel="stylesheet" href="css/public.css" media="all">
	</head>
	<body>

		<form class="layui-form layui-from-pane" action="" style="margin-top:20px" lay-filter="formMenu">
			
			<input name="id" type="hidden" value="">

			<div class="layui-form-item">
				<label class="layui-form-label">菜单名称</label>
				<div class="layui-input-block">
					<input type="text" name="menuname"  required  lay-verify="required" autocomplete="off" placeholder="请输入菜单名称" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">菜单类型</label>
				<div class="layui-input-block">
				  <input type="radio" name="type" value="0" title="目录">
				  <input type="radio" name="type" value="1" title="菜单">
				  <input type="radio" name="type" value="2" title="按钮">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">菜单地址</label>
				<div class="layui-input-block">
					<input type="text" name="url"  required  lay-verify="required" autocomplete="off" placeholder="请输入菜单地址" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">菜单权限</label>
				<div class="layui-input-block">
					<input type="text" name="permission"  autocomplete="off" placeholder="请输入菜单权限" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item" style="margin-top:40px">
				<div class="layui-input-block">
					<button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="demo11">确认修改</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>

	<div>
		<p>标题:</p>
		<h2 class="zx-title"></h2>
		<hr/>
		<div>
			<span class="type"></span>
			<span class="readNum">0</span>阅读
			<span class="publictime"></span>
			<span class="commentNum">0</span>条评论
			<span class="collectNum">0</span>人收藏
		</div>
		<textarea id="content" style="display: none;"></textarea>
		<div class="comments">

		</div>
	</div>



<script src="lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="api/baseApi.js" charset="utf-8"></script>
<script>
		layui.use(['laydate','table','layer','form'], function(){
					var form = layui.form
					,layer = layui.layer
					$ = layui.$;
					var layedit = layui.layedit;

			//获取页面传过来的数据
			let localData = layui.sessionData("menuData");

			//给表单赋值
			form.val('formMenu',localData.menu);


			//监听提交
			form.on('submit(demo11)', function(data) {
				//layer.msg(JSON.stringify(data.field));
				$.ajax({
					url: baseUrl + menuBaseUrl,
					type:'put',
					dataType: "json",
					contentType: "application/json;charset=UTF-8",
					data: JSON.stringify(data.field),
					success:function (res) {
						if(res.success){
							parent.layer.msg('菜单修改成功',{time:1000},function () {
								parent.location.reload();
							})
						}else{
							layer.msg(res.msg);
						}
					}

				})

				return false;
			});

		layui.use(['layer','layedit'], function(){
			var layer = layui.layer;
			var $ = layui.$;
			var layedit = layui.layedit;
			var index = layedit.build('content',{
				height:500
			}); //建立编辑器

			//获取页面传过来的数据
			let localData = layui.sessionData("zxData");

			let zxId = localData.zx.id;


			$.ajax({
				url: baseUrl + zxBaseUrl + zxId ,
				type: 'get' ,
				dataType: "json",
				contentType: "application/json;charset=UTF-8",
				success:function (res) {

					console.log(res.comments);
					let zx = res.zxArticle;
					let comments = res.comments;
					$('.zx-title').html(zx.title);
					$('.type').text(zx.name);
					$('.readNum').text(zx.readNum);
					$('.publictime').text(zx.publictime);
					$('.commentNum').text(zx.commentNum);
					$('.collectNum').text(zx.collectNum);
					$('.content').text(zx.content);
					var index = layedit.build('content',{
						height:300
					}); //建立编辑器

				}
			})

		});
</script>
</body>
</html>